package exercise;

import java.util.Scanner;

public class Text3 {
    public static void main(String[] args) {
        // 目标：完成评委打分案例。
        System.out.println("当前选手得分是:" + getAverageScore(6));
    }

    public static double getAverageScore(int number) {
        // 定义一个动态初始化数组，负责后期存入评委的打分
        int[] scores = new int[number];
        // 遍历数组，依次录入分数。
        Scanner sc = new Scanner(System.in);
        for (int i = 0; i < scores.length; i++) {
            System.out.println("请录入第" + (i + 1) + "个评委的分数：");
            int score = sc.nextInt();
            scores[i] = score;
        }

        int sum = 0;
        int max = scores[0];
        int min = scores[0];

        for (int i = 0; i < scores.length; i++) {
            int score = scores[i];
            sum += score;
            if (score > max) {
                max = score;
            }
            if (score < min) {
                min = score;
            }
        }

        return 1.0 * (sum - max - min) / (number - 2);
    }
}
